import pandas as pd
df = pd.read_csv('city.csv', sep=';')
df
df.rename(str.upper, axis=1, inplace=True)
df
df.info()
df[ df.DISTRICT.isna() ]
df.dropna(inplace=True)
df.info()
df = df[ df.POPULATION > 1000000 ].copy()
df.drop('DISTRICT', axis=1, inplace=True)
df
df.to_excel('test.xlsx', index=False)
df2 = pd.DataFrame({
'country': ['France', 'USA', 'Ukraine'],
'capital': ['Paris', 'Washington', 'Kiev'],
'population': [66.99, 328.2, 41.98]
})
df2
with pd.ExcelWriter('cities2.xlsx') as writer:
df2.to_excel(writer, sheet_name='TestSheet', index=False)
df.to_excel(writer, sheet_name='TestSheet', index=False, startrow=(len(df2) + 6))
df.shape[0]
len(df)